#include <system/Mouse.h>

namespace ne
{
    const uint32_t Mouse::MAX_MOUSE_BUTTONS = 8;

    Mouse::Mouse()
        : mPosition(Vector2::ZERO),
          mWheelVariation(0.0f),
          mButtonsDown(MB_NONE_BUTTON)
    {
    }

    void Mouse::setPosition(const Vector2 &v)
    {
        mPosition = v;
    }

    Vector2 Mouse::getPosition() const
    {
        return mPosition;
    }

    void Mouse::setPosition(const real x, const real y)
    {
        mPosition.x = x;
        mPosition.y = y;
    }

    void Mouse::getPosition(real &x, real &y) const
    {
        x = mPosition.x;
        y = mPosition.y;
    }

    void Mouse::setButtonUp(const MouseButton button)
    {
        mButtonsDown -= mButtonsDown & button;
    }

    bool Mouse::isButtonUp(const MouseButton button) const
    {
        if (mButtonsDown & button)
        {
            return false;
        }
        return true;
    }

    void Mouse::setButtonDown(const MouseButton button)
    {
        mButtonsDown |= button;
    }

    bool Mouse::isButtonDown(const MouseButton button) const
    {
        if (mButtonsDown & button)
        {
            return true;
        }
        return false;
    }

    uint32_t Mouse::getButtonsDown() const
    {
        return mButtonsDown;
    }

    void Mouse::setWheelVariation(const real v)
    {
        mWheelVariation = v;
    }

    real Mouse::getWheelVariation() const
    {
        return mWheelVariation;
    }

    void Mouse::reset()
    {
        mPosition = Vector2::ZERO;
        mWheelVariation = 0.0f;
        mButtonsDown = MB_NONE_BUTTON;
    }

    Mouse::~Mouse()
    {
    }
}
